//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a sample for BCGControlBar Library Professional Edition
// Copyright (C) 1998-2009 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions 
// of the accompanying license agreement.
//*******************************************************************************
//
// ImageStyle.cpp: implementation of the bcg_skins class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "bcg_skins.h"
#include "dll_object.h"
#include "dlg_wrapper.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

IMPLEMENT_DYNCREATE(bcg_skins, CBCGPVisualManager2007)

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

bcg_skins::bcg_skins()
{
	m_brOutlook.CreateSolidBrush (RGB(63, 134, 178));
}
//*********************************************************************************
bcg_skins::~bcg_skins()
{

}

//*********************************************************************************
void bcg_skins::OnFillOutlookPageButton (CDC* pDC, const CRect& rect,
										BOOL bIsHighlighted, BOOL bIsPressed,
										COLORREF& clrText)
{
	CBitmap bmp;
	if ( bIsPressed )
	{
		if ( !bmp.LoadBitmap (IDB_OUTLOOK_SEL_BTN) )
		{
			return;
		}
	}
	else
	{
		if ( !bmp.LoadBitmap (IDB_OUT_LOOK_BTN) )
		{
			return;
		}
	}


	BITMAP bmpInfo;
	bmp.GetBitmap(&bmpInfo);
	CDC dcMemory;
	dcMemory.CreateCompatibleDC(pDC);
	CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
	int nX = rect.left;
	int nY = rect.top;

	pDC->StretchBlt(nX, nY, rect.Width(), rect.Height(), &dcMemory, 
		0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,SRCCOPY);

	dcMemory.SelectObject(pOldBitmap);
	clrText = RGB (0, 0, 0);
	return;
}

void 
bcg_skins::OnFillOutlookBarCaption( CDC* pDC, CRect rectCaption, COLORREF& clrText )
{
	CBitmap bmp;
	if (!bmp.LoadBitmap (IDB_CAPTION_BG))
	{
		return;
	}

	BITMAP bmpInfo;
	bmp.GetBitmap(&bmpInfo);
	CDC dcMemory;
	dcMemory.CreateCompatibleDC(pDC);
	CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
	int nX = rectCaption.left + 1;
	int nY = rectCaption.top + 1;

	pDC->StretchBlt(nX, nY, rectCaption.Width() - 2, rectCaption.Height() - 2 , &dcMemory, 
		0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,SRCCOPY);

	dcMemory.SelectObject(pOldBitmap);
	clrText = RGB (0, 0, 0);
}


void bcg_skins::OnDrawOutlookBarSplitter( CDC* pDC, CRect rectSplitter )
{
	
}

void bcg_skins::OnFillBarBackground( CDC* pDC, CBCGPBaseControlBar* pBar, CRect rectClient, CRect rectClip, BOOL bNCArea /*= FALSE*/ )
{
	if (pBar->IsKindOf (RUNTIME_CLASS (CBCGPOutlookBarPane)))
	{
		pDC->FillRect (rectClip, &m_brOutlook);
		return;
	}

	CBCGPVisualManager2007::OnFillBarBackground(pDC, pBar, rectClient, rectClip, bNCArea);

	if ( bNCArea )
	{
		return;
	}

	CBitmap bmp;
	if ( !bmp.LoadBitmap (IDB_OUTLOOK_BOTTOM) )
	{
		return;
	}
	
	BITMAP bmpInfo;
	bmp.GetBitmap(&bmpInfo);
	CDC dcMemory;
	dcMemory.CreateCompatibleDC(pDC);
	CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);
	int nX = rectClient.left;
	int nY = rectClient.top;

	pDC->StretchBlt(nX, nY, rectClient.Width(), rectClient.Height(), &dcMemory, 
		0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight,SRCCOPY);
	dcMemory.SelectObject(pOldBitmap);
}

void bcg_skins::OnDrawOutlookPageButtonBorder( CDC* pDC, CRect& rectBtn, BOOL bIsHighlighted, BOOL bIsPressed )
{

}
